package com.kingsoft.dc.khaos.module.spark.model.TechCheck;


import java.io.PrintWriter;
import java.io.StringWriter;

public class KsyunTechCheckException extends RuntimeException {

    KsyunErrorCode errorCode;
    public KsyunTechCheckException(KsyunErrorCode code , Exception e){
        super(code.toString(),e);
        this.errorCode = errorCode;
    }
    public KsyunTechCheckException(String msg, Exception e){
        super(msg,e);
        this.errorCode = KsyunErrorCode.DEFAULT_ERROR;
    }
    public KsyunTechCheckException(String msg){
        super(msg);
        this.errorCode = KsyunErrorCode.DEFAULT_ERROR;
    }

    public KsyunTechCheckException(KsyunErrorCode code){
        super(code.toString());
        this.errorCode = code;
    }

    public KsyunTechCheckException(KsyunErrorCode code, String msg){
        super(code.toString() +"! " + msg );
        this.errorCode = code;
    }
    public KsyunErrorCode getErrorCode(){
        return errorCode;
    }

    public static String getExceptionToString(Throwable e) {
        if (e == null){
            return "";
        }
        StringWriter stringWriter = new StringWriter();
        e.printStackTrace(new PrintWriter(stringWriter));
        return stringWriter.toString();
    }
}
